package com.hrt.datasender.web.bcdeviceconfig;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import com.btcode.web.core.annotation.RequestMapping;
import com.btcode.web.core.controller.Controller;
import com.hrt.common.web.DSRequestUnit;
import com.hrt.datasender.datadao.model.BcDeviceConfigModel;
import com.hrt.datasender.datadao.service.BcDeviceConfigService;

@RequestMapping(path = "BcDeviceConfig")
public class BcDeviceConfigController extends Controller {

    @RequestMapping(path = "getList")
    public void getList(ServletRequest arg0, ServletResponse arg1) throws IOException {

        String deviceId = DSRequestUnit.getString("deviceId");
        List<BcDeviceConfigModel> devices = BcDeviceConfigService.getInstance().getList(deviceId);

        success(devices);
    }

    @RequestMapping(path = "create")
    public void create(ServletRequest arg0, ServletResponse arg1) throws IOException {

        BcDeviceConfigModel model = DSRequestUnit.getModel(BcDeviceConfigModel.class);
        BcDeviceConfigService.getInstance().create(model);
    }

    @RequestMapping(path = "creates")
    public void creates(ServletRequest arg0, ServletResponse arg1) throws IOException {

        List<BcDeviceConfigModel> models = DSRequestUnit.getModels(BcDeviceConfigModel.class);
        BcDeviceConfigService.getInstance().creates(models);
    }

    @RequestMapping(path = "update")
    public void update(ServletRequest arg0, ServletResponse arg1) throws IOException {

        BcDeviceConfigModel model = DSRequestUnit.getModel(BcDeviceConfigModel.class);
        BcDeviceConfigService.getInstance().update(model);
    }
}
